﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Game_Fly.Code
{
    public class BulletTwo
    {
        //1.字段变量：xy坐标，图片，速度，宽度，高度
        int x;
        int y;
        Image image;
        int speed;//表示子弹一次移动多少个像素
        int width;
        int height;
        int frequency;//子弹发射频率
        //2.属性方法
        public int X
        {
            set { x = value; }
            get { return x; }
        }

        public int Y
        {
            set { y = value; }
            get { return y; }
        }

        public int Width
        {
            set { width = value; }
            get { return width; }
        }

        public int Height
        {
            set { height = value; }
            get { return height; }
        }
        public int Frequency//子弹发射频率
        {
            set { frequency = value; }
            get { return frequency; }
        }
        //3.构造方法
        public BulletTwo()
        {
            x = 240;
            y = GameUI.GameForm.ClientSize.Height;
            image = GameImage.ZiDan1;
            speed = 15;
            width = image.Width;
            height = image.Height;
            frequency = 10;
        }

        //4.特征方法
        public void Draw(Graphics g)
        {
            g.DrawImage(image, x, y);
        }

        public void Update(int frame)
        {
            //让子弹往上飞
            y -= speed;
            //判断子弹是否超出边界
            if (y <= -height)
                GameUI.ListBulletsTwo.Remove(this);
        }
    }
}
